/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedbean;

import Beans.CustomerReservationBeanRemote;
import CustomerIOTRPortal.FakeMainPortalMB;
import Entity.OutletReservation;
import java.io.Serializable;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ActionEvent;

/**
 *
 * @author Lu Xiaodi
 */
@ManagedBean (name = "reservationManagedBean") 
@ViewScoped
public class ReservationManagedBean implements Serializable {

    @EJB
    CustomerReservationBeanRemote reservationBean; 
    
    @ManagedProperty(value = "#{fakeMainPortalMB}")
    private FakeMainPortalMB portalManagedBean;
            
    private String customerEmail;
    private String dateStr;
    
    public ReservationManagedBean (){
       //outletName = "McdonaldNUS";
    }
    
    public List<OutletReservation> getReservationByCus(){
        return reservationBean.getReservationByCustomerOutlet(getCustomerEmail(), portalManagedBean.getOutletId());
    }
    
    public void recordShowUp(ActionEvent event){
//        System.out.println("im here");
        Long rId = (Long) event.getComponent().getAttributes().get("rId");
        reservationBean.recordShowUp(portalManagedBean.getOutletId(), rId);
    }
    
    public List<OutletReservation> getReservationByDate(){
        List<OutletReservation> list = reservationBean.getReservationByDateOutlet(dateStr, portalManagedBean.getOutletId());
        return list;
    }
    
    public void confirmOneReservation(ActionEvent event){
       // System.out.println("im here");
        Long rId = (Long)event.getComponent().getAttributes().get("rId");
        reservationBean.confirmReservation(portalManagedBean.getOutletId(), rId);
    }
    
    public String getDateStr() {
        return dateStr;
    }

    public void setDateStr(String dateStr) {
        this.dateStr = dateStr;
    }

    public FakeMainPortalMB getPortalManagedBean() {
        return portalManagedBean;
    }

    public void setPortalManagedBean(FakeMainPortalMB portalManagedBean) {
        this.portalManagedBean = portalManagedBean;
    }
    
    public Long getOutletId() {
        return portalManagedBean.getOutletId();
    }

    public String getCustomerEmail() {
        return customerEmail;
    }

    public void setCustomerEmail(String customerEmail) {
        this.customerEmail = customerEmail;
    }
}